import { createRouter, createWebHistory } from 'vue-router'
import Home from '../views/Home'
import Sheet from '../views/sheet/sheet.vue'
import lyricDetail from '../components/lyricDetail/lyricDetail.vue'
// import Search from '../views/Search/Search.vue'
import store from '@/store/index.js'
const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/sheet',
    name: 'Sheet',
    component: Sheet
  },
  {
    path: '/lyricdetail',
    name: 'lyricDetail',
    component: lyricDetail
  },
  {
    path:'/search',
    name:'Search',
    component: import('@/views/Search/Search.vue')
  },
  {
    path:'/login',
    name:'Login',
    component: import('@/views/Login/Login.vue')
  },
  {
    path:'/info',
    name:'Info',
    beforeEnter:(to,form,next)=>{
  if(store.state.isLogin){
    next()
  }
  else{
    next('/login')
  }
    },
    component: import('@/views/My/Info.vue')
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
